package com.click369.crm.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.click369.crm.mapper.CDeptMapper;
import com.click369.crm.mapper.CPositionMapper;
import com.click369.crm.pojo.CDept;
import com.click369.crm.pojo.CPosition;
import com.click369.crm.pojo.QueryVO;
import com.click369.crm.service.PositionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class PositionServiceImpl implements PositionService{
	
	@Autowired
	private CPositionMapper positionMapper;
	
	//添加
	@Override
	public void save(CPosition post) {
		post.setCreateTime(new Date());
		positionMapper.insert(post);
	}
	//根据id删除
	@Override
	public void delete(Integer id) {
		positionMapper.deleteByPrimaryKey(id);
	}
	//修改
	@Override
	public void update(CPosition post) {
		post.setUpdateTime(new Date());
		positionMapper.updateByPrimaryKey(post);
	}
	//查询所有分页
	@Override
	public PageInfo<CPosition> select(Integer page, Integer rows, CPosition post) {
		//分页
		PageHelper.startPage(page,rows);
		List<CPosition> list=positionMapper.select(post);
		return new PageInfo(list);
	}
	//根据id查询
	@Override
	public CPosition getById(Integer id) {
		return positionMapper.selectByPrimaryKey(id);
	}
}
